//
//  CBLocalizedKey.swift
//  FoundationCustom
//
//  Created by ZhouJiatao on 2018/10/26.
//  Copyright © 2018 Unknow. All rights reserved.
//

import Foundation


/// 该app支持的语言种类
public enum CBLanguage: String {
    case simplifiedChinese = "SCN" // 编码是后台定义的
    case traditionalChinese = "TCN"
    case english = "EN"
    
    public var description: String {
        switch self {
        case .simplifiedChinese: return "简体中文"
        case .traditionalChinese: return "繁体中文"
        case .english: return "英文"
        
        }
    }
    
    /// iOS 的语言标识
    public var localeIdentifier: String {
        switch self {
        case .simplifiedChinese: return "zh-Hans"
        case .traditionalChinese: return "zh-Hant"
        case .english: return "en"
            
        }
    }
}

/// 本地化资源的key
public enum CBLocalizedKey: String {
    
    
    case input_hint$incorrect_phone = "input_hint$incorrect_phone"
    case input_hint$incorrect_image_code = "input_hint$incorrect_image_code"
    case input_hint$incorrect_sms_code = "input_hint$incorrect_sms_code"
    //case operation_hint$register_success = "operation_hint$register_success"
    
    
    /// 默认对应的本地化字符串
    public var defaultLocalizedValue: String {
        
        switch self {
        
        case .input_hint$incorrect_phone: return"请输入正确的手机号码"
        case .input_hint$incorrect_image_code: return "图形验证码错误"
        case .input_hint$incorrect_sms_code: return "短信验证码错误"
            
            
        //case .operation_hint$register_success: return "注册成功"
            
        }
        
    }
    
}


public class CBLocalized {
    
    public static let shared = CBLocalized()
    
    /// 字典：本地化资源。
    public var dictionary: [String: String] = [String: String]()
    
    /// 系统语言
    public static var systemLanguage: CBLanguage {
        // TODO: 获取系统语言
        return .simplifiedChinese
    }
    
    /// 真正使用的语言
    public var currentLanguage: CBLanguage = CBLocalized.systemLanguage
    
    
}



